package com.everyday.practice.leetCode;

public class Title509 {

    public static void main(String[] args) {
        System.out.println(fib(3));
        System.out.println(fib(7));
        System.out.println(fib(4));
    }

    public static int fib(int n){
        if (n<=1){
            return n;
        }
        int pre =0;
        int next=1;
        for (int i=2;i<=n;i++){
            int count=pre+next;
            pre=next;
            next=count;
        }
        return next;
    }
}
